#include "CParticle.h"

CParticle::CParticle()
{
}
CParticle::~CParticle()
{

}
void CParticle::Init(float posX, float posY, float velX, float velY, float lifeSpan, float scale, float Xgrav, float Ygrav, D3DXCOLOR scolor, D3DXCOLOR ecolor)
{
	startPosX = m_fPosX = posX;
	startPosY = m_fPosY = posY;
	m_fInitialVelX = m_fVelX = velX;
	m_fInitialVelY = m_fVelY = velY;
	m_flifeSpan = lifeSpan;
	m_fscale = scale;
	startColor = scolor;
	endColor = ecolor;
	colorChange = ecolor - scolor;
	m_fAge = 0;
	gravX = Xgrav;
	gravY = Ygrav;
}
void CParticle::Update(float fDelta)
{
	if(m_fAge == 0)
	{
		m_fVelX = m_fInitialVelX;
		m_fVelY = m_fInitialVelY;
		m_fPosX = startPosX;
		m_fPosY = startPosY;
	}
	m_fVelX = m_fVelX + (gravX * fDelta);
	m_fPosX = m_fPosX + (m_fVelX * (fDelta * 2));
	m_fVelY = m_fVelY + (gravY * fDelta);
	m_fPosY = m_fPosY + (m_fVelY * (fDelta * 2));
	currColor = startColor + (colorChange * (m_fAge/m_flifeSpan));
	m_fAge += fDelta;
}
void CParticle::Shutdown()
{

}